package io.renren.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.renren.common.entity.XlsCommodityEntity;
import io.renren.common.service.impl.CrudServiceImpl;
import io.renren.dao.XlsCommodityDao;
import io.renren.dto.XlsCommodityDTO;
import io.renren.service.XlsCommodityService;
import io.renren.utils.AppResult;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 商品表
 *
 * @author Mark sunlightcs@gmail.com
 * @since 1.0.0 2020-04-09
 */
@Service
public class XlsCommodityServiceImpl extends CrudServiceImpl<XlsCommodityDao, XlsCommodityEntity, XlsCommodityDTO> implements XlsCommodityService {

    @Autowired
    private XlsCommodityDao xlsCommodityDao;

    @Override
    public QueryWrapper<XlsCommodityEntity> getWrapper(Map<String, Object> params){
        String id = (String)params.get("id");

        QueryWrapper<XlsCommodityEntity> wrapper = new QueryWrapper<>();
        wrapper.eq(StringUtils.isNotBlank(id), "id", id);

        return wrapper;
    }


    @Override
    public AppResult getCommodityInfo() {
        List<Map<String,Object>> commodityList=xlsCommodityDao.getCommodityInfo();
        return AppResult.OK(commodityList);
    }

    @Override
    public AppResult getCommodityDeatil(XlsCommodityEntity xlsCommodityEntity) {
        Map<String,Object> xlsCommodityDTO=xlsCommodityDao.getCommodityDeatil(xlsCommodityEntity);
        return AppResult.OK(xlsCommodityDTO);
    }
}